
Type.registerNamespace('AjaxDataControls');
$ADC.GridViewDropDownListColumn=function(){
this._dataSource;
this._hasBinded=false;
this._readOnly=false;
this._dataField='';
this._dataTextField='';
this._dataTextFormatString='';
this._dataValueField='';
$ADC.GridViewDropDownListColumn.initializeBase(this);
$ADC.GridViewDropDownListColumn.callBaseMethod(this,'set_allowDragAndDrop',[false]);}
$ADC.GridViewDropDownListColumn.prototype=
{
initialize:function(){
$ADC.GridViewBaseColumn.callBaseMethod(this,'initialize');},
dispose:function(){
delete this._dataSource;
delete this._hasBinded;
delete this._readOnly;
delete this._dataField;
delete this._dataTextField;
delete this._dataTextFormatString;
delete this._dataValueField;
$ADC.GridViewBaseColumn.callBaseMethod(this,'dispose');},
get_readOnly:function(){
if(arguments.length!==0)throw Error.parameterCount();
return this._readOnly;},
set_readOnly:function(value){
var e=Function._validateParams(arguments,[{name:'value',type:Boolean}]);
if(e)throw e;
if(this._readOnly!=value){
this._readOnly=value;
this.raisePropertyChanged('readOnly');}},
get_dataField:function(){
if(arguments.length!==0)throw Error.parameterCount();
return this._dataField;},
set_dataField:function(value){
var e=Function._validateParams(arguments,[{name:'value',type:String}]);
if(e)throw e;
if(this._dataField!=value){
this._dataField=value;
this.raisePropertyChanged('dataField');}},
get_dataTextField:function(){
if(arguments.length!==0)throw Error.parameterCount();
return this._dataTextField;},
set_dataTextField:function(value){
var e=Function._validateParams(arguments,[{name:'value',type:String}]);
if(e)throw e;
if(this._dataTextField!=value){
this._dataTextField=value;
this.raisePropertyChanged('dataTextField');}},
get_dataTextFormatString:function(){
if(arguments.length!==0)throw Error.parameterCount();
return this._dataTextFormatString;},
set_dataTextFormatString:function(value){
var e=Function._validateParams(arguments,[{name:'value',type:String}]);
if(e)throw e;
if(this._dataValueField!=value){
this._dataTextFormatString=value;
this.raisePropertyChanged('dataTextFormatString');}},
get_dataValueField:function(){
if(arguments.length!==0)throw Error.parameterCount();
return this._dataValueField;},
set_dataValueField:function(value){
var e=Function._validateParams(arguments,[{name:'value',type:String}]);
if(e)throw e;
if(this._dataValueField!=value){
this._dataValueField=value;
this.raisePropertyChanged('dataValueField');}},
get_dataSource:function(){
if(arguments.length!==0)throw Error.parameterCount();
return this._dataSource;},
set_dataSource:function(value){
var e=Function._validateParams(arguments,[{name:'value',type:String,mayBeNull:true}]);
if((e==null)&&(value!=null))
value=eval(value);
e=Function._validateParams(arguments,[{name:'value',type:Array,mayBeNull:true}]);
if(e)throw e;
if(this._dataSource!=value){
this._dataSource=value;
this._hasBinded=false;}},
_renderSelect:function(dataSource,select,selectedItem){
var e=Function._validateParams(arguments,[{name:'dataSource',type:Array},{name:'select',domElement:true},{name:'selectedItem',type:Object}]);
if(e)throw e;
var dataValueField=this.get_dataValueField();
var dataTextField=this.get_dataTextField();
var dataFormatString=this.get_dataTextFormatString();
var firstItemText="";
var value=null;
var text='';
if(this.get_readOnly()){
value=selectedItem.Value;
text=selectedItem.Text;
if(!$ADC.Util.isEmptyString(dataFormatString))
text=text.localeFormat(dataFormatString);
this._addItem(select,text,value);
select.selectedIndex=0;}
else{
this._addItem(select,firstItemText,"");
var selectedValue=selectedItem.Value;
for(var index=0;index<dataSource.length;index++){
value=dataSource[index].Value;
text=dataSource[index].Text;
if(!$ADC.Util.isEmptyString(dataFormatString))
text=text.localeFormat(dataFormatString);
this._addItem(select,text,value,dataSource[index]);
if(value==selectedValue)
select.selectedIndex=(index+1);
value=null;
text="";}
if(selectedValue=="none")
select.selectedIndex=0;}},
_addItem:function(select,text,value,item){
var e=Function._validateParams(arguments,[{name:'select',domElement:true},{name:'text',type:String},{name:'value',type:String},{name:'item',type:Object,mayBeNull:true,optional:true}]);
if(e)throw e;
if(typeof item=='undefined')item=null;
var opt=document.createElement('option');
opt.get_item=function(){return item;}
select.appendChild(opt);
if(typeof opt.innerText!='undefined')
opt.innerText=text;
else if(typeof opt.textContent!='undefined')
opt.textContent=text;
if(value!=null)
opt.value=value;},
renderData:function(dataRow,row,container){
var e=Function._validateParams(arguments,[{name:'dataRow',type:Object},{name:'row',type:$ADC.GridViewRow},{name:'container',type:Object}]);
if(e)throw e;
var dataField=this.get_dataField();
if($ADC.Util.isEmptyString(dataField))
throw Error.invalidOperation('DataField set before calling this method.');
var dataValueField=this.get_dataValueField();
if($ADC.Util.isEmptyString(dataValueField))
throw Error.invalidOperation('DataValueField set before calling this method.');
var dataTextField=this.get_dataTextField();
if($ADC.Util.isEmptyString(dataTextField))
throw Error.invalidOperation('DataTextField set before calling this method.');
var dataSource=this.get_dataSource();
var e=Function._validateParameter(dataSource,Array,false,false);
if(e)throw Error.invalidOperation('DataSource set before calling this method.');
var value=null;
if((dataField!=null)&&(dataField.length>0))
value=dataRow[dataField];
if(value==null){
value=dataSource[0];}
else{
for(var index=0;index<dataSource.length;index++){
if(dataSource[index].Value==value){
value=dataSource[index];
break;}}}
if((row.get_rowType()==$ADC.GridViewRowType.EditRow)){
var select=document.createElement('select');
select.disabled=this.get_readOnly();
this._renderSelect(dataSource,select,value);
select.get_selectedItem=function(){return this.options[this.selectedIndex].get_item();};
select.get_selectedValue=function(){return this.options[this.selectedIndex].get_item().Value;};
select.get_selectedText=function(){return this.options[this.selectedIndex].get_item().Text;};
container.appendChild(select);
if(this.get_controlStyle()!=null)
this.get_controlStyle().apply(select);}
else{
value=(value!=null)?value.Text:"Unbound";
container.appendChild(document.createTextNode(value));}
if(this.get_itemStyle()!=null)
this.get_itemStyle().apply(container);
this._hasBinded=true;}}
$ADC.GridViewDropDownListColumn.registerClass('AjaxDataControls.GridViewDropDownListColumn',$ADC.GridViewBaseColumn);
if(typeof(Sys)!='undefined')Sys.Application.notifyScriptLoaded();